// pages/group-head/after-sale.js
const tabs = [{
        name: "待退货",
        status: 20
    },
    {
        name: "已退款",
        status: 21
    },
]
Page({

    /**
     * 页面的初始数据
     */
    data: {
        list: [{
                community_group_name: "河滨森邻生鲜便利群",
                goodsItems: [{
                    goods_id: "46",
                    images: "https://img.zhxcxmall.com/community/goods/cover/154200419201441412917.jpg",
                    name: "千足金 缅甸黄金 99K纯金",
                    order_id: "22",
                    price: "0.01",
                    quantity: "1",
                    sku: "1盎司"
                }],
                id: "22",
                name: "李二柱",
                quantity_total: "1",
                status: "-1",
                total_cost: "0.01",
            },
            {
                community_group_name: "河滨森邻生鲜便利群",
                goodsItems: [{
                    goods_id: "46",
                    images: "https://img.zhxcxmall.com/community/goods/cover/154200419201441412917.jpg",
                    name: "千足金 缅甸黄金 99K纯金",
                    order_id: "22",
                    price: "0.01",
                    quantity: "1",
                    sku: "1盎司"
                }],
                id: "22",
                name: "李二柱",
                quantity_total: "1",
                status: "-1",
                total_cost: "0.01",
            },
            {
                community_group_name: "河滨森邻生鲜便利群",
                goodsItems: [{
                    goods_id: "46",
                    images: "https://img.zhxcxmall.com/community/goods/cover/154200419201441412917.jpg",
                    name: "千足金 缅甸黄金 99K纯金",
                    order_id: "22",
                    price: "0.01",
                    quantity: "1",
                    sku: "1盎司"
                }],
                id: "22",
                name: "李二柱",
                quantity_total: "1",
                status: "-1",
                total_cost: "0.01",
            }
        ],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        let statusObj = {}
        Object.keys(tabs).forEach(k => {
            statusObj[tabs[k].status] = tabs[k].name
        })
        this.setData({
            statusObj,
            tabs,
        })
    },
    clickTab(evt) {
        const status = evt.currentTarget.dataset.status
        if (status != this.data.status) {
            this.setData({
                status
            })
            let tab = pool.get(this.data.status)
            console.log(tab, 'tab')
            if (tab && tab.list.length == 0) {
                tab.page = 1
                tab.total = 2
            }
            this.loadData()
        }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})